
'use strict';

module.exports = app => {
    const sequelize = app.Sequelize;

  const Model = app.model.define(
    'ttb_push', {
      id: {
        type: sequelize.INTEGER(11),
        primaryKey: true,
        autoIncrement: true
      },
      uuid:{
        type: sequelize.STRING(200),
        allowNull: false,
      },
      title:{
        type: sequelize.STRING(50),
        allowNull: true,
        defaultValue:0,
      },
      name:{
        type: sequelize.STRING(200),
        allowNull: false,
      },
      content:{
        type: sequelize.STRING(5000),
        allowNull: false,
      },
      imgs:{
        type: sequelize.STRING(1000),
        allowNull: true,
      },
      platform:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      schedule:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      modality:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      modality_value:{
        type: sequelize.STRING(500),
        allowNull: true,
      },
      schedule_time_cron:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      schedule_time_cron_analyzing:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      target:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      tag_ids:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      rigids:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      alias:{
        type: sequelize.STRING,
        allowNull: true,
      },
      skip_online:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      extras_map:{
        type: sequelize.STRING(2000),
        allowNull: true,
      },
      next_type:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      next_type_link:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      next_type_scheme_params:{
        type: sequelize.STRING(2000),
        allowNull: true,
      },
      tag:{
        type: sequelize.STRING(2000),
        allowNull: true,
      },
      status:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      schedule_uuid:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      alias_tag_ids:{
        type: sequelize.STRING,
        allowNull: true,
      },
      schedule_time:{
        type: sequelize.STRING(50),
        allowNull: true,
      },
      alias_tag_alias:{
        type: sequelize.STRING,
        allowNull: true,
      },
      batch_id:{
        type: sequelize.STRING(200),
        allowNull: true,
      },
      create_time: {
        type:sequelize.DATE,
        defaultValue:sequelize.now,
        get() {
          let t = this.getDataValue('create_time');
          t = t ? app.utils.time.moment(t).format('YYYY-MM-DD HH:mm:ss') :'';
          return t ;
        }
      },
      update_time: {
        type: sequelize.DATE,
        defaultValue:sequelize.now,
        get() {
          let t = this.getDataValue('update_time');
          t = t ? app.utils.time.moment(t).format('YYYY-MM-DD HH:mm:ss') :'';
          return t ;
        }
      },
      delete_time: {
        type: sequelize.DATE,
        defaultValue:null,
        get() {
          let t = this.getDataValue('delete_time');
          t = t ? app.utils.time.moment(t).format('YYYY-MM-DD HH:mm:ss') :'';
          return t ;
        }
      },
      rollback_time: {
        type:sequelize.DATE,
        defaultValue:sequelize.now,
        get() {
          let t = this.getDataValue('rollback_time');
          t = t ? app.utils.time.moment(t).format('YYYY-MM-DD HH:mm:ss') :'';
          return t ;
        }
      },
      cancel_time: {
        type: sequelize.DATE,
        defaultValue:sequelize.now,
        get() {
          let t = this.getDataValue('cancel_time');
          t = t ? app.utils.time.moment(t).format('YYYY-MM-DD HH:mm:ss') :'';
          return t ;
        }
      },
    },
    {
      tableName: 'ttb_push', //自定义映射数据库真实表名
      timestamps:false,
      // freezeTableName: true,  //强制表名等于模型名
    },
  );

  return Model;
}